<meta charset="utf-8">

<div class="box box-primary" id="pmpTasks_submit" style="height: 480px;">

	<form role="form" id="pmpTasks_submit_editForm" >
		<div class="box-body">
			  	
			  	<label>任务名称:  {{task_name}} </label>
			  	<hr>
			  	<label>分配时长:  {{assign_hours}} (hours)</label>
			  	<hr>
			  	<div class="form-group">
						<label>工作时长</label> 
						<input name="workHours" v-model="submitDto.workHours" id="workHours" type="number" placeholder="" class="form-control">
				</div>
					
			  	<div class="form-group">
				  	<label for="title">任务完成度:({{submitDto.progress}}%)</label><br> 
					<input type="range"  min="0" max="100"   step="1" data-rangeslider_progress>
			  	</div>
			  	<div class="form-group">
						<label>工作备注</label> 
						<input name="remark" v-model="submitDto.remark" id="remark" type="text" placeholder="" class="form-control">
					</div>
			  	
                         
					<div class="form-group" v-if="submitDto.progress>=100">
						<label for="title">是否提交任务</label>
						   <select name="isSumitTask" v-model="submitDto.isSumitTask" id="isSumitTask"  class="form-control">
						   <option value="">请选择</option>
						   	<option value="1">提交</option>
						   	<option value="0">不提交</option>
						   </select>
					</div>
					
					
		</div>
		
		<div class="box-footer">
			<button type="button" class="btn btn-default" v-on:click="cancel">取消</button>
			<button type="button" class="btn btn-info pull-right" v-on:click="doAsign">提交</button>
		</div>
		
	</form>
</div>
<script type="text/javascript">

var pmpTasks_submit_main=	new Vue({
			el : '#pmpTasks_submit',
			data : {
				task_name: zfesLayerEditDg.getLayerParam().task_name,
				assign_hours: zfesLayerEditDg.getLayerParam().assign_hours,
				submitDto:{
					 id: zfesLayerEditDg.getLayerParam().id,
					 progress: zfesLayerEditDg.getLayerParam().progress,
					 workHours: zfesLayerEditDg.getLayerParam().work_hours,
					 isSumitTask: null,
					 remark: ''
				},
				
				bus : new Vue()
			},
			mounted : function() {
				var _this = this;
				_this.submitDto.progress= zfesLayerEditDg.getLayerParam().progress;
				_this.submitDto.workHours= zfesLayerEditDg.getLayerParam().work_hours;
				_this.initSlider();
				setTimeout(function(){var t=_this.progress;_this.progress=100; _this.progress=t;}, 100);
			},
			methods : {
				initSlider: function(){
					var _this = this;
						var $document   = $(document);
					   	var selector    = '[data-rangeslider_progress]';
					   	var $inputRange = $(selector);
					     $inputRange.rangeslider({ polyfill: false});
					     $document.on('input',selector, function(e) {
					        pmpTasks_submit_main.$data.submitDto.progress=e.target.value
					       console.log( _this.$data.submitDto.progress);
					    });
					setTimeout(function(){$inputRange.val(_this.$data.submitDto.progress).change(); }, 100);
				},
			
				doAsign : function() {
					if ($("#pmpTasks_submit_editForm").valid()) {
						var _this = this;
				        var url = "/pmp/service/dev/pmpTasks/submitTasks";
				        if(_this.progress>=100){
				        	if(!isSumitTask){
				        		 alertSwal.warning("请选择是否提交审核");
				        		 return;
				        	}
				        }
				       zfesAjax.ajaxTodo(url, _this.submitDto, function(data) {
				    	   alertSwal.successText(data.message);
							layer.close(layer.index);
				       });
					}
				},
				cancel : function() {
					layer.close(layer.index);
				}
			}
		});
</script>
